home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Belgian Amiga Club - ADF Collection
/
BS1 part 05.zip
/
BS1 part 5
/
IM_Install3.adf
/
piarc.LZH
/
pcxload.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1992-07-30
|
6KB
|
197 lines
/*
* PCXload.rexx Load Z Soft / PC Paintbrush PCX files
*
* Written by: Barry Chalmers
* Last Update: July 31st, 1992
* For: Black Belt Systems image processing series IM, IM F/c, and IP.
* ---------------------------------------------------------------------------
* Revision: 1.00 - Initial version 1,4, and 8 bit files
*/
/*
* open rexxsupport.library -- needed for some functions
*/
if ~show('L',"rexxsupport.library") then do
if addlib('rexxsupport.library',0,-30,0) then do
/* everything's ok */
end;
else do
say 'We Have A Library Problem, Unable To Load "rexxsupport.library"';
say 'Cannot operate script without this library - sorry!';
exit 10;
end;
end;
/*
* This will automatically direct the script to the proper
* software, if it is running.
*/
prtnme = 'IP_Port'; /* assume Image Professional */
if show('P','IP_Port') = 0 then do
if show('P','IM_Port') = 0 then do
say "Can't find image processor's ARexx port!!!"; /* not running? */
say "This script requires IP, IM or IM F/c to run!";
exit(20);
end;
else do
prtnme = 'IM_Port'; /* That's the thing about assumptions... */
end; /* We make em, user's break em. */
end;
cmdpath = 'c:';
if open(fhandle,'rexx:picmdpath','read') then /* open the file */
do
cmdpath = readln(fhandle);
call close(fhandle); /* close the file */
end
prevpath = 'ram:'; /* put user in ram to start with... */
if show('C',rgbpath) = 1 then do
prevpath = getclip(rgbpath);
end;
prevname = '';
if show('C',rgbname) = 1 then do
prevname = getclip(rgbname);
end;
address(prtnme);
'autoredraw 0';
options results;
'filerequest "'||prevpath||'","'||prevname||'",".pcx","Load PCX"';
rgbfile = result;
options;
if rgbfile = 'FR_CANCELLED' then do
address(prtnme);
'tofront';
exit 0;
end;
rgbfile = expandfilename(rgbfile);
prevpath = gimmepath(rgbfile);
call setclip(rgbpath,prevpath);
prevname = gimmename(rgbfile);
call setclip(rgbname,prevname);
prevext = gimmeext(rgbfile);
address command 'cmpi:PCXload report '||rgbfile;
if open(fhandle,'ram:PCX.report','read') then /* open the file */
do
xw = readln(fhandle);
yw = readln(fhandle);
call close(fhandle); /* close the file */
end
'newasprimary '||xw||','||yw||','||prevname;
address(prtnme);
options results;
'jackin';
jack = result;
options;
address command 'cmpi:PCXload load '||jack||' '||rgbfile;
address(prtnme);
'autoredraw 1';
'redraw';
exit 0; /* The end */
/*
* gimmepath
*
* This takes the provided argument and sucks the path out of it, then
* returns that path to the caller, sans file name.
*/
gimmepath:
arg fullnamegx;
tempgx = reverse(fullnamegx);
lengx = length(fullnamegx); /* get length of string */
slashdex = index(tempgx,'/'); /* first occurance of '/' from right */
colondex = index(tempgx,':'); /* first occurance of ':' from right */
seploc = 0; /* assumes current dir, no path supplied */
if slashdex ~= 0 then do /* we assume we are in a DIR */
seploc = (lengx - slashdex)+1;
end;
else do
if colondex ~= 0 then do /* we assume we are on a device */
seploc = (lengx - colondex)+1;
end;
end;
gxname = substr(fullnamegx,seploc+1); /* if you ever need it */
gxpath = left(fullnamegx,seploc);
return(gxpath);
/*
* Since this script can't be expected to know where the CD of the user
* is when this cmd is invoked, we have to check the path the user
* provides - if it's not specified right from a root, then we have
* to make it a complete specification from the root.
*/
expandfilename:
parse arg jfile;
if index(jfile,':') = 0 then do
curdir = pragma(D);
if right(curdir,1) ~= ':' then do
if right(curdir,1) ~= '/' then do
if curdir ~= '' then do
curdir = curdir || '/';
end;
end;
end;
jfile = curdir||jfile;
end;
return(jfile);
gimmename:
arg fullnamegx;
tempgx = reverse(fullnamegx);
lengx = length(fullnamegx); /* get length of string */
slashdex = index(tempgx,'/'); /* first occurance of '/' from right */
colondex = index(tempgx,':'); /* first occurance of ':' from right */
seploc = 0; /* assumes current dir, no path supplied */
if slashdex ~= 0 then do /* we assume we are in a DIR */
seploc = (lengx - slashdex)+1;
end;
else do
if colondex ~= 0 then do /* we assume we are on a device */
seploc = (lengx - colondex)+1;
end;
end;
extpos = lastpos(".",fullnamegx) - 2;
if extpos > seploc then do
gxname = substr(fullnamegx,seploc+1,extpos-seploc+1);
end;
else do
gxname = substr(fullnamegx,seploc+1);
end;
return(gxname);
end
gimmeext:
arg fullnamegx;
tempgx = reverse(fullnamegx);
lengx = length(fullnamegx); /* get length of string */
slashdex = index(tempgx,'/'); /* first occurance of '/' from right */
colondex = index(tempgx,':'); /* first occurance of ':' from right */
seploc = 0; /* assumes current dir, no path supplied */
if slashdex ~= 0 then do /* we assume we are in a DIR */
seploc = (lengx - slashdex)+1;
end;
else do
if colondex ~= 0 then do /* we assume we are on a device */
seploc = (lengx - colondex)+1;
end;
end;
extpos = lastpos(".",fullnamegx) - 2;
if extpos > seploc then do
gxext = substr(fullnamegx,extpos+2);
end;
else do
gxext = '';
end;
return(gxext);
end